package com.blb.marry.controller;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.blb.marry.entity.Hotel;
import com.blb.marry.entity.Package;
import com.blb.marry.entity.Room;
import com.blb.marry.service.HotelService;
import com.blb.marry.service.PackageService;
import com.blb.marry.service.RoomService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpSession;
import java.util.ArrayList;
import java.util.List;

/**
 * @author lvtian
 * @date 2023/1/17 12:55
 */
@Controller
public class PackageController {
    @Autowired
    private PackageService packageService;
    @Autowired
    private RoomService roomService;
    @Autowired
    private HotelService hotelService;
    //套餐详情页信息
    @RequestMapping("/getPackage")
    public String getPackage(Long packageId , Model model ){
        System.out.println(packageId);
//        通过packageid查到套餐详细信息
        Package pkg = packageService.getPackageByPackageId(packageId);
//        通过package里的hotelid查到酒店信息
        Hotel hotel = hotelService.getHotel(pkg.getTbHotelHotelId());
        //通过hotelid查到酒店的room信息
        List<Room> rooms = roomService.getRoomById(pkg.getTbHotelHotelId());
        ArrayList<Integer> cur = new ArrayList<>();
        model.addAttribute("pkg",pkg);
        model.addAttribute("hotel",hotel);
        model.addAttribute("rooms",rooms);

        return "forward:/packageDetails.html";
    }

}
